﻿using System;
using System.Data;
using System.Text;
using MySql.Data.MySqlClient;
using Maticsoft.DBUtility;//Please add references
namespace becom.DAL
{
	/// <summary>
	/// 数据访问类:oa_meeting_notice
	/// </summary>
	public partial class oa_meeting_notice
	{
		public oa_meeting_notice()
		{}
		#region  Method

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
		return DbHelperMySQL.GetMaxID("ID", "oa_meeting_notice"); 
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int ID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from oa_meeting_notice");
			strSql.Append(" where ID=@ID");
			MySqlParameter[] parameters = {
					new MySqlParameter("@ID", MySqlDbType.Int32)
};
			parameters[0].Value = ID;

			return DbHelperMySQL.Exists(strSql.ToString(),parameters);
		}


		/// <summary>
		/// 增加一条数据
		/// </summary>
		public void Add(becom.Model.oa_meeting_notice model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into oa_meeting_notice(");
			strSql.Append("MeetingTheme,MeetingAddress,MeetingIsJournal,MeetingIsSMS,MeetingStatus,MeetingDateStar,MeetingDateEnd,MeetingCreateDate,MeetingCreateCode,CreateDate)");
			strSql.Append(" values (");
			strSql.Append("@MeetingTheme,@MeetingAddress,@MeetingIsJournal,@MeetingIsSMS,@MeetingStatus,@MeetingDateStar,@MeetingDateEnd,@MeetingCreateDate,@MeetingCreateCode,@CreateDate)");
			MySqlParameter[] parameters = {
					new MySqlParameter("@MeetingTheme", MySqlDbType.VarChar,50),
					new MySqlParameter("@MeetingAddress", MySqlDbType.VarChar,100),
					new MySqlParameter("@MeetingIsJournal", MySqlDbType.Int32,11),
					new MySqlParameter("@MeetingIsSMS", MySqlDbType.Int32,11),
					new MySqlParameter("@MeetingStatus", MySqlDbType.Int32,11),
					new MySqlParameter("@MeetingDateStar", MySqlDbType.DateTime),
					new MySqlParameter("@MeetingDateEnd", MySqlDbType.DateTime),
					new MySqlParameter("@MeetingCreateDate", MySqlDbType.DateTime),
					new MySqlParameter("@MeetingCreateCode", MySqlDbType.VarChar,10),
					new MySqlParameter("@CreateDate", MySqlDbType.DateTime)};
			parameters[0].Value = model.MeetingTheme;
			parameters[1].Value = model.MeetingAddress;
			parameters[2].Value = model.MeetingIsJournal;
			parameters[3].Value = model.MeetingIsSMS;
			parameters[4].Value = model.MeetingStatus;
			parameters[5].Value = model.MeetingDateStar;
			parameters[6].Value = model.MeetingDateEnd;
			parameters[7].Value = model.MeetingCreateDate;
			parameters[8].Value = model.MeetingCreateCode;
			parameters[9].Value = model.CreateDate;

			DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(becom.Model.oa_meeting_notice model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update oa_meeting_notice set ");
			strSql.Append("MeetingTheme=@MeetingTheme,");
			strSql.Append("MeetingAddress=@MeetingAddress,");
			strSql.Append("MeetingIsJournal=@MeetingIsJournal,");
			strSql.Append("MeetingIsSMS=@MeetingIsSMS,");
			strSql.Append("MeetingStatus=@MeetingStatus,");
			strSql.Append("MeetingDateStar=@MeetingDateStar,");
			strSql.Append("MeetingDateEnd=@MeetingDateEnd,");
			strSql.Append("MeetingCreateDate=@MeetingCreateDate,");
			strSql.Append("MeetingCreateCode=@MeetingCreateCode,");
			strSql.Append("CreateDate=@CreateDate");
			strSql.Append(" where ID=@ID");
			MySqlParameter[] parameters = {
					new MySqlParameter("@MeetingTheme", MySqlDbType.VarChar,50),
					new MySqlParameter("@MeetingAddress", MySqlDbType.VarChar,100),
					new MySqlParameter("@MeetingIsJournal", MySqlDbType.Int32,11),
					new MySqlParameter("@MeetingIsSMS", MySqlDbType.Int32,11),
					new MySqlParameter("@MeetingStatus", MySqlDbType.Int32,11),
					new MySqlParameter("@MeetingDateStar", MySqlDbType.DateTime),
					new MySqlParameter("@MeetingDateEnd", MySqlDbType.DateTime),
					new MySqlParameter("@MeetingCreateDate", MySqlDbType.DateTime),
					new MySqlParameter("@MeetingCreateCode", MySqlDbType.VarChar,10),
					new MySqlParameter("@CreateDate", MySqlDbType.DateTime),
					new MySqlParameter("@ID", MySqlDbType.Int32,11)};
			parameters[0].Value = model.MeetingTheme;
			parameters[1].Value = model.MeetingAddress;
			parameters[2].Value = model.MeetingIsJournal;
			parameters[3].Value = model.MeetingIsSMS;
			parameters[4].Value = model.MeetingStatus;
			parameters[5].Value = model.MeetingDateStar;
			parameters[6].Value = model.MeetingDateEnd;
			parameters[7].Value = model.MeetingCreateDate;
			parameters[8].Value = model.MeetingCreateCode;
			parameters[9].Value = model.CreateDate;
			parameters[10].Value = model.ID;

			int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int ID)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from oa_meeting_notice ");
			strSql.Append(" where ID=@ID");
			MySqlParameter[] parameters = {
					new MySqlParameter("@ID", MySqlDbType.Int32)
};
			parameters[0].Value = ID;

			int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 批量删除数据
		/// </summary>
		public bool DeleteList(string IDlist )
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from oa_meeting_notice ");
			strSql.Append(" where ID in ("+IDlist + ")  ");
			int rows=DbHelperMySQL.ExecuteSql(strSql.ToString());
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public becom.Model.oa_meeting_notice GetModel(int ID)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ID,MeetingTheme,MeetingAddress,MeetingIsJournal,MeetingIsSMS,MeetingStatus,MeetingDateStar,MeetingDateEnd,MeetingCreateDate,MeetingCreateCode,CreateDate from oa_meeting_notice ");
			strSql.Append(" where ID=@ID");
			MySqlParameter[] parameters = {
					new MySqlParameter("@ID", MySqlDbType.Int32)
};
			parameters[0].Value = ID;

			becom.Model.oa_meeting_notice model=new becom.Model.oa_meeting_notice();
			DataSet ds=DbHelperMySQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				if(ds.Tables[0].Rows[0]["ID"]!=null && ds.Tables[0].Rows[0]["ID"].ToString()!="")
				{
					model.ID=int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
				}
				if(ds.Tables[0].Rows[0]["MeetingTheme"]!=null && ds.Tables[0].Rows[0]["MeetingTheme"].ToString()!="")
				{
					model.MeetingTheme=ds.Tables[0].Rows[0]["MeetingTheme"].ToString();
				}
				if(ds.Tables[0].Rows[0]["MeetingAddress"]!=null && ds.Tables[0].Rows[0]["MeetingAddress"].ToString()!="")
				{
					model.MeetingAddress=ds.Tables[0].Rows[0]["MeetingAddress"].ToString();
				}
				if(ds.Tables[0].Rows[0]["MeetingIsJournal"]!=null && ds.Tables[0].Rows[0]["MeetingIsJournal"].ToString()!="")
				{
					model.MeetingIsJournal=int.Parse(ds.Tables[0].Rows[0]["MeetingIsJournal"].ToString());
				}
				if(ds.Tables[0].Rows[0]["MeetingIsSMS"]!=null && ds.Tables[0].Rows[0]["MeetingIsSMS"].ToString()!="")
				{
					model.MeetingIsSMS=int.Parse(ds.Tables[0].Rows[0]["MeetingIsSMS"].ToString());
				}
				if(ds.Tables[0].Rows[0]["MeetingStatus"]!=null && ds.Tables[0].Rows[0]["MeetingStatus"].ToString()!="")
				{
					model.MeetingStatus=int.Parse(ds.Tables[0].Rows[0]["MeetingStatus"].ToString());
				}
				if(ds.Tables[0].Rows[0]["MeetingDateStar"]!=null && ds.Tables[0].Rows[0]["MeetingDateStar"].ToString()!="")
				{
					model.MeetingDateStar=DateTime.Parse(ds.Tables[0].Rows[0]["MeetingDateStar"].ToString());
				}
				if(ds.Tables[0].Rows[0]["MeetingDateEnd"]!=null && ds.Tables[0].Rows[0]["MeetingDateEnd"].ToString()!="")
				{
					model.MeetingDateEnd=DateTime.Parse(ds.Tables[0].Rows[0]["MeetingDateEnd"].ToString());
				}
				if(ds.Tables[0].Rows[0]["MeetingCreateDate"]!=null && ds.Tables[0].Rows[0]["MeetingCreateDate"].ToString()!="")
				{
					model.MeetingCreateDate=DateTime.Parse(ds.Tables[0].Rows[0]["MeetingCreateDate"].ToString());
				}
				if(ds.Tables[0].Rows[0]["MeetingCreateCode"]!=null && ds.Tables[0].Rows[0]["MeetingCreateCode"].ToString()!="")
				{
					model.MeetingCreateCode=ds.Tables[0].Rows[0]["MeetingCreateCode"].ToString();
				}
				if(ds.Tables[0].Rows[0]["CreateDate"]!=null && ds.Tables[0].Rows[0]["CreateDate"].ToString()!="")
				{
					model.CreateDate=DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString());
				}
				return model;
			}
			else
			{
				return null;
			}
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ID,MeetingTheme,MeetingAddress,MeetingIsJournal,MeetingIsSMS,MeetingStatus,MeetingDateStar,MeetingDateEnd,MeetingCreateDate,MeetingCreateCode,CreateDate ");
			strSql.Append(" FROM oa_meeting_notice ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperMySQL.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			MySqlParameter[] parameters = {
					new MySqlParameter("@tblName", MySqlDbType.VarChar, 255),
					new MySqlParameter("@fldName", MySqlDbType.VarChar, 255),
					new MySqlParameter("@PageSize", MySqlDbType.Int32),
					new MySqlParameter("@PageIndex", MySqlDbType.Int32),
					new MySqlParameter("@IsReCount", MySqlDbType.Bit),
					new MySqlParameter("@OrderType", MySqlDbType.Bit),
					new MySqlParameter("@strWhere", MySqlDbType.VarChar,1000),
					};
			parameters[0].Value = "oa_meeting_notice";
			parameters[1].Value = "ID";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperMySQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  Method
	}
}

